package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 关联回款选择类型
 * @author yuqian
 * @version v1.0
 * @date 2019/11/4 17:21
 * @since v1.0
 */
@Getter
public enum PaymentRelationshipEnum {
    //关联付款选择类型
    PAYMENT("1","payment", "enum.paymentRelationship.name.payment"),
    PAYMENT_SHEET("2","payment_sheet", "enum.paymentRelationship.name.payment_sheet"),
    UNKNOWN("404","", "enum.paymentRelationship.name.unknown");

    private String code;
    private String name;
    private String alias;

    PaymentRelationshipEnum(String code,String name,String alias){
        this.code = code;
        this.name = name;
        this.alias = alias;
    }

    public static PaymentRelationshipEnum getByCode(String code){
        for(PaymentRelationshipEnum cacheCode : values()){
            if(code.equals(cacheCode.getCode())){
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public String getAlias() {
        return I18nMessageUtil.getMessage(alias);
    }
}
